<template>
	<!-- 自定义头部 -->
	<view>
		<view class="status-bar" :style="'height:'+menuButtonInfo.top+'px'"></view>
		<!-- 页面顶部 -->
		<view class="head" :style="'top:'+menuButtonInfo.top+'px'">
			<image class="back"  @click="backClick" src="/static/images/back.png" mode="" ></image>
			<view :style="'height:'+menuButtonInfo.height+'px;line-height:'+menuButtonInfo.height+'px;color:'+color" class="title one-overflow">{{title}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:'Header',
		data() {
			return {
				menuButtonInfo:{},//右上角胶囊信息
				pages_length:0,//页面栈长度
			}
		},
		props:{
			title:{type:String,default:''},
			color:{
				type:String,default:'#000'
			}
		},
		mounted() {
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			console.log('menuButtonInfo',this.menuButtonInfo)
			this.pages_length = getCurrentPages().length
		},
		methods: {
			// 点击返回上一页
			backClick(){
				uni.navigateBack()
			},
			// 点击跳转首页
			homeClick(){
				uni.reLaunch({
					url:'../src/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
// 自定义头部
.status-bar{
	width: 100%;
	z-index: 999;
	left: 0;
	top: 0;
}
.head{
	left: 0;
	width: 100%;
	z-index: 999;
	display: flex;
	justify-content: center;
	align-items: center;
	height: 80rpx;
	.title{
		width: 300rpx;
		color: #000;
		font-size: 33rpx;
		text-align: center;
	}
	.back{
		width: 48rpx;
		height: 48rpx;
		position: absolute;
		left: 20rpx;
	}
}
</style>
